from poco.drivers.android.uiautomation import AndroidUiautomationPoco
poco = AndroidUiautomationPoco(use_airtest_input=True,screenshot_each_action=False)
from poco.exceptions import PocoTargetTimeout
from airtest.core.api import *
#点击
# poco(desc="驾考宝典").click()
# double_click((659,567))
# poco(desc="驾考宝典",type = "android.widget.ImageView").click()
# poco(desc="驾考宝典").long_click(duration=5)

#输入
# poco(name="com.handsgo.jiakao.android:id/edt_search_q").set_text("唐门优测")
#对象存在判断
# invisible = poco(desc="驾考宝典111")
# print(invisible.exists())
# 拖动和滑动
# 选择UI
# poco("com.handsgo.jiakao.android:id/ivRemote").drag_to(poco("com.handsgo.jiakao.android:id/titleTv"))
# # poco("com.handsgo.jiakao.android:id/ivRemote").drag_to(poco(text = "科一"))
# # poco("com.handsgo.jiakao.android:id/ivRemote").swipe([+0.5,+0.5])
# poco("com.handsgo.jiakao.android:id/ivRemote").swipe("up")
# poco("com.handsgo.jiakao.android:id/ivRemote").swipe("down")
# poco("com.handsgo.jiakao.android:id/ivRemote").swipe("left")
# poco("com.handsgo.jiakao.android:id/ivRemote").swipe("right")
#不选中UI
# x,y = poco("com.handsgo.jiakao.android:id/ivRemote").get_position()
# end = [x,y +0.3]
# #从A点滑到B点
# poco.swipe([x,y],end)

#等待元素出现或消失
# poco("驾考宝典").wait_for_appearance(timeout=10)

# try:
#     poco("驾考宝典").wait_for_disappearance(timeout=5)
# except PocoTargetTimeout:
#     snapshot(filename=r"D:\daima\xin-daima\kejian\airtest_demo/656.png",msg="元素出现或者未出现")

# "#轮询UI等待,任意一个UI出现就往下走"
# jiakao =poco("驾考宝典")
# dingding=poco("钉钉 1 个未读")
# meituan=poco("美团")
# poco.wait_for_any([jiakao,dingding,meituan])
# poco("驾考宝典").click()

# "#轮询UI时等待，所有UI出现才往下走"
# jiakao =poco("驾考宝典")
# xianyu=poco("闲鱼")
# poco.wait_for_all([jiakao,xianyu])
# poco("驾考宝典").click()

#打开APP
# start_app("com.handsgo.jiakao.android")
# sleep(5)
# stop_app("com.handsgo.jiakao.android")